var express = require('express');
const { uploadFile } = require("tools-factory-tang");
const { update, deleteImg ,updatePoster} = require("../api/cinemas");


// 路由
var router = express.Router();

// 处理上传 成功后拿到的东西
router.post("/upload", async function (req, res, next) {
    const { data } = await uploadFile(req, { fileType: "cinemas" });//fileType分类
    const result = await update(data);
    res.send(result)
});

// // 海报
// router.post("/uploadPoster", async function (req, res, next) {
//     const { data } = await uploadFile(req, { fileType: "moviesPoester" });//fileType分类 
//     const result = await updatePoster(data);
//     res.send(result);
// });

//删除 imgs 对应值 
router.delete("/:_id/imgs/:url", async function (req, res, next) {
    const { _id, url } = req.params;
    const result = await deleteImg({ _id, url })
    res.send(result);
});



module.exports = router;